
#include "Impl_Scene.h"

_BeginNamespace(Radix)
/*
=================================================================
== Node
=================================================================
*/
Node::Node(const String& name, INode* parent)
	:mName(name),
	mParent(parent),
	mChildren(),
	mEntity(nullptr)
{}

Node::~Node()
{
	this->deleteChildren();
	this->detachEntity();
}

const String& Node::name()
{
	return mName;
}

INode* Node::parent()
{
	return mParent;
}

INode* Node::child(const String& nodeName)
{
	return mChildren.select(nodeName);
}

INode* Node::createChild(const String& nodeName)
{
	return mChildren.insert<Node, String, Node*>(nodeName, nodeName, this);
}

void Node::deleteChild(const String& nodeName)
{
	mChildren.remove(nodeName);
}

void Node::deleteChildren()
{
	mChildren.clear();
}

IEntity* Node::entity()
{
	return mEntity;
}

bool Node::attachEntity(IEntity* entity)
{
	if(mEntity != nullptr)
		return false;
	mEntity = entity;
	return true;
}

void Node::detachEntity()
{
	mEntity = nullptr;
}

/*
=================================================================
== UniverseScene
=================================================================
*/
UniverseScene::UniverseScene(const String& name)
	:mName(name),
	mRootNode(new Node(_T(""), nullptr))
{}

UniverseScene::~UniverseScene()
{
	delete mRootNode;
}

const String& UniverseScene::name()
{
	return mName;
}

const String& UniverseScene::type()
{
	static const String skName = _T("UniverseScene");
	return skName;
}

INode* UniverseScene::rootNode()
{
	return mRootNode;
}
/*
=================================================================
== TerrainScene
=================================================================
*/
TerrainScene::TerrainScene(const String& name)
	:mName(name),
	mRootNode(new Node(_T(""), nullptr))
{}

TerrainScene::~TerrainScene()
{
	delete mRootNode;
}

const String& TerrainScene::name()
{
	return mName;
}

const String& TerrainScene::type()
{
	static const String skName = _T("TerrainScene");
	return skName;
}

INode* TerrainScene::rootNode()
{
	return mRootNode;
}
/*
=================================================================
== IndoorScene
=================================================================
*/
IndoorScene::IndoorScene(const String& name)
	:mName(name),
	mRootNode(new Node(_T(""), nullptr))
{}

IndoorScene::~IndoorScene()
{
	delete mRootNode;
}

const String& IndoorScene::name()
{
	return mName;
}

const String& IndoorScene::type()
{
	static const String skName = _T("IndoorScene");
	return skName;
}

INode* IndoorScene::rootNode()
{
	return mRootNode;
}

/*
=================================================================
== SceneSystem
=================================================================
*/

_EndNamespace(Radix)
